#ifndef CONTEXT_H_
#define CONTEXT_H_

// Number of mezzanines
#define NB_MEZZA 6

// Log pathfile max length
#define LOG_PATH_LENGTH 64

// Game color type structure
typedef enum {yellow, blue} gameColor;

// Game configuration structure
typedef struct gameConfiguration
{
	unsigned char lateralConfig;
	unsigned char centralConfig;
	
} gameConfiguration;

// Robot motion structure
// Units are TICKS ! (not mm or pixel)
typedef struct robotMotion
{		
	// Position
	int x;	
	int y;
	int d;
	int a;
	
	// Speed
	int vx;	
	int vy;
	int vd;
	int va;
	
	// Acceleration
	int ax;
	int ay;
	int ad;
	int aa;
	
	// PID values (examples, to be adjusted)
	int KI;
	int KP;
	int KD;
	
} robotMotion;

// Robot actuators state
typedef struct robotActuators
{
	// Exemples...
	unsigned char servo1;
	int pwm1;	
	
} robotActuators;

// Robot sensors state
typedef struct robotSensors
{
	// Exemples
	unsigned int ultraSonic1;
	unsigned char colorSensor1;
	
} robotSensors;

// Exemples, to be continued and improved
typedef enum {forward, backward, turnleft, turnright} robotState;


// Batteries state monitoring structure
// units in mV and mA
typedef struct monitorBatteries
{
	// Exemples, 2 elements
	// we monitor voltage and current
	unsigned int el1Voltage;
	unsigned int el2Voltage;
	
	unsigned int el1Current;
	unsigned int el2Current;
	
	// Threshold
	unsigned int threshold;
} monitorBatteries;

// Voltages monitoring structure
// units in mV
typedef struct monitorVoltages
{
	unsigned int voltage3V3;
	unsigned int voltage5V;
	unsigned int voltage24V;
	
	// Threshold
	unsigned int threshold;
} monitorVoltages;

// Currents monitoring structure
// units in mA
typedef struct monitorCurrents
{
	unsigned int current3V3;
	unsigned int current5V;
	unsigned int current24V;
	
	unsigned int mezza[NB_MEZZA];
	
	// Threshold
	unsigned int threshold;
} monitorCurrents;

// Temperatures monitoring structure
// units in m°C
typedef struct monitorTemperatures
{
	// Exemples...
	unsigned int arm;
	unsigned int spartan3;
	
	// Threshold
	unsigned int threshold;
} monitorTemperatures;
/*
 * --------------------
 * Context strucutre
 * --------------------
 */
 
 typedef struct context
 {
 	// --------------------
 	// Global parameters
 	// --------------------
 	
 	// Log Y or N ?
 	unsigned char log;
 	
 	// Log path
 	char logPath[LOG_PATH_LENGTH];
 	
 	// Backlight
 	unsigned char backlight;
 	unsigned char maxBacklight;
 	
 	// Sound volume
 	unsigned char volume;
 	
 	// Wireless reception level
 	unsigned char wireless;
 	
 	// --------------------
 	// Game informations
 	// --------------------
 	
 	// Run ?
 	unsigned char run;
 	
 	// Score (in grammes)
 	unsigned int score;
 	
 	// Time left (in seconds)
 	unsigned char timeLeft;
 	
 	// Game color type
 	gameColor color;
 	
 	// Game configuration
 	gameConfiguration configuration;
 	
 	// --------------------
 	// Robot informations
 	// --------------------
 	
 	// Position, Speed and Acceleration
 	// and other motion variables
 	robotMotion motion;
 	
 	// Actuators state
 	robotActuators actuators;
 	
 	// Sensors state
 	robotSensors sensors;
 	
 	// Robot state
 	robotState state;
 	
 	// --------------------
 	// Monitoring
 	// --------------------
 	
 	// Batterie
 	monitorBatteries batteries;
 	
 	// Voltages
 	monitorVoltages voltages;
 	
 	// Currents
 	monitorCurrents currents;
 	
 	// Temperatures
 	monitorTemperatures temperatures;
 	 	
 } context;
#endif /*CONTEXT_H_*/
